#include "Entity.h"

using namespace std;

Entity::Entity(void) {
	position.set(0, 0, 0);
	orientation.set(0, 0, -1);
	up.set(0, 1, 0);
}

Entity::~Entity(void)
{
}

///

void Entity::MoveBy(VectorXYZ v) {
	position = position + v;
}

void Entity::MoveBy(float XCoord, float YCoord, float ZCoord) {
	VectorXYZ temp(XCoord, YCoord, ZCoord);

	position = position + temp;
}

void Entity::MoveTo(VectorXYZ v) {
	position.set(v.x, v.y, v.z);
}

void Entity::MoveTo(float XCoord, float YCoord, float ZCoord) {
	position.set(XCoord, YCoord, ZCoord);
}

///

void Entity::RotateBy(float angle, VectorXYZ axis) {
	orientation.rotate(angle, axis);
	up.rotate(angle, axis);
}

void Entity::RotateBy(float angle, float XCoord, float YCoord, float ZCoord) {
	VectorXYZ temp (XCoord, YCoord, ZCoord);

	RotateBy(angle, temp);
}

void Entity::RotateTo(VectorXYZ axis) {
	up.rotate(orientation, axis);
	axis.Normalize();
	orientation.set(axis);
}

// Convenience rotations

void Entity::Pitch(float angle) {
	RotateBy(angle, up % orientation);
}

void Entity::Yaw(float angle) {
	RotateBy(angle, -up);
}

void Entity::Roll(float angle) {
	RotateBy(angle, -orientation);
}

//

float Entity::MinimumCameraDistance() {
	return 0.f;
}